Azure Web App CLI Commands Guide
Table of Contents
🌐 Introduction
Azure Web Apps provide a powerful platform-as-a-service (PaaS) solution for hosting web applications. The Azure CLI offers comprehensive commands to manage every aspect of your web apps, from creation and configuration to deployment and monitoring. This guide covers the essential az webapp commands and their practical applications.
📋 Prerequisites
Before using Azure Web App CLI commands, ensure you have:
- Azure CLI installed and configured
- An active Azure subscription
- Appropriate permissions to create and manage Azure resources
# Login to Azure
az login
# Set your default subscription
az account set --subscription "Your-Subscription-Name"🚀 Web App Management
Creating Web Apps
Create a new web app
# Create a resource group
az group create --name diginsighttools-testmc-rg-itn-01 --location "Italy North"
# Create an App Service plan
az appservice plan create --name diginsighttools-testmc-asp-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --sku FREE
# Create a web app
az webapp create --resource-group diginsighttools-testmc-rg-itn-01 --plan diginsighttools-testmc-asp-itn-01 --name diginsighttools-testmc-job-itn-01 --runtime "NODE:18-lts"Create web app with specific configurations
# Create web app with custom settings
az webapp create \
--resource-group diginsighttools-testmc-rg-itn-01 \
--plan diginsighttools-testmc-asp-itn-01 \
--name diginsighttools-testmc-job-itn-01 \
--runtime "PYTHON:3.9" \
--startup-file "app.py"Listing and Viewing Web Apps
List all web apps in subscription
az webapp list --output tableList web apps in specific resource group
az webapp list --resource-group diginsighttools-testmc-rg-itn-01 --output tableShow detailed information about a web app
az webapp show --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01Get web app URL
az webapp show --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --query defaultHostName --output tsv⚙️ Configuration and Settings
App Settings Management
List all app settings
az webapp config appsettings list --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01Set app settings
# Set single app setting
az webapp config appsettings set --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --settings "ENVIRONMENT=production"
# Set multiple app settings
az webapp config appsettings set \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--settings "DATABASE_URL=your-db-url" "API_KEY=your-api-key"Delete app settings
az webapp config appsettings delete --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --setting-names "OLD_SETTING"Connection Strings
Set connection strings
az webapp config connection-string set \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--connection-string-type SQLServer \
--settings "DefaultConnection=Server=myserver;Database=mydb;..."List connection strings
az webapp config connection-string list --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01📦 Deployment Operations
Source Control Deployment
Configure continuous deployment from GitHub
az webapp deployment source config \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--repo-url https://github.com/username/repository \
--branch main \
--manual-integrationConfigure deployment from local Git
az webapp deployment source config-local-git \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01ZIP and Local Git Deployment
Deploy from ZIP file
az webapp deployment source config-zip \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--src path/to/your/app.zipGet deployment credentials
az webapp deployment list-publishing-credentials \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01Show deployment history
az webapp deployment list-publishing-profiles \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01🔧 Advanced Management
Scaling and Performance
Scale web app instances
# Scale to specific number of instances
az webapp scale --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --instance-count 3
# Enable auto-scaling
az monitor autoscale create \
--resource-group diginsighttools-testmc-rg-itn-01 \
--resource diginsighttools-testmc-job-itn-01 \
--resource-type Microsoft.Web/sites \
--name diginsighttools-testmc-autoscale \
--min-count 1 \
--max-count 10 \
--count 2Restart web app
az webapp restart --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01Stop and start web app
# Stop web app
az webapp stop --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01
# Start web app
az webapp start --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01Monitoring and Diagnostics
Enable application logging
az webapp log config \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--application-logging filesystem \
--level informationStream logs
az webapp log tail --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01Download log files
az webapp log download --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --log-file logs.zip🔒 Security and Access
SSL/TLS Configuration
Bind SSL certificate
az webapp config ssl bind \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--certificate-thumbprint your-cert-thumbprint \
--ssl-type SNIUpload SSL certificate
az webapp config ssl upload \
--name diginsighttools-testmc-job-itn-01 \
--resource-group diginsighttools-testmc-rg-itn-01 \
--certificate-file path/to/certificate.pfx \
--certificate-password your-passwordEnable HTTPS only
az webapp update --name diginsighttools-testmc-job-itn-01 --resource-group diginsighttools-testmc-rg-itn-01 --https-only true📚 References
Official Documentation
Azure CLI Web App Commands Reference - Complete reference documentation for all
az webappcommands, including syntax, parameters, and examples. Essential for understanding all available options and command variations.Azure App Service CLI Samples - Collection of practical CLI scripts and examples for common App Service scenarios. Valuable for learning real-world implementation patterns and best practices.
Best Practices and Guides
Azure App Service Deployment Best Practices - Comprehensive guide covering deployment strategies, slot management, and CI/CD integration. Important for understanding production deployment workflows and avoiding common pitfalls.
Azure CLI Tips and Tricks - Advanced techniques for using Azure CLI efficiently, including output formatting, querying, and automation. Helpful for improving productivity and creating robust automation scripts.
Security and Configuration
App Service Authentication and Authorization - Detailed explanation of built-in authentication features and configuration options. Critical for implementing secure access controls and identity integration.
Configure SSL/TLS Certificates in Azure App Service - Step-by-step guide for SSL certificate management and HTTPS configuration. Essential for securing web applications and meeting compliance requirements.
Monitoring and Troubleshooting
Monitor Azure App Service Performance - Guide to monitoring tools, metrics, and diagnostic features available in App Service. Valuable for maintaining application health and performance optimization.
Azure App Service Diagnostics - Overview of built-in diagnostic tools and troubleshooting capabilities. Important for quickly identifying and resolving application issues in production environments.